package com.easy.common.enumbean;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

public enum OrderStatus {
    //'待付款', '已成交', '已取消'
    OBLIGATION("待付款"),TRANSACTED("已成交"),CANCELLED("已取消");

    @EnumValue
    private String value;
    private OrderStatus(String value) {
        this.value = value;
    }
    @JsonValue
    public String getValue() {
        return this.value;
    }

    @JsonCreator
    public static  OrderStatus convert(String val){
        switch (val){
            case "待付款":
                return OBLIGATION;
            case "已成交":
                return TRANSACTED;
            case "已取消":
                return CANCELLED;

            default:
                throw new RuntimeException("没有对应的枚举类型");
        }
    }

    public String valueOf(){
        return this.value;
    }
    public String toString() {
        return this.value;
    }
}
